package io.github.iogogogo.commons.support.wrapper;

/**
 * Created by tao.zeng on 2024/11/7.
 */
public interface BaseResult {

    int _OK_CODE = 200;
    String _OK_MESSAGE = "ok";

    default <T> ResponseWrapper<T> ok() {
        return ok(_OK_CODE);
    }

    default <T> ResponseWrapper<T> ok(int code) {
        return ok(code, null, _OK_MESSAGE);
    }

    default <T> ResponseWrapper<T> ok(T data) {
        return ok(_OK_CODE, data, _OK_MESSAGE);
    }

    default <T> ResponseWrapper<T> ok(String message) {
        return ok(_OK_CODE, null, message);
    }

    default <T> ResponseWrapper<T> ok(T data, String message) {
        return ok(_OK_CODE, data, message);
    }

    default <T> ResponseWrapper<T> ok(int code, T data, String message) {
        return result(code, data, message);
    }

    default <T> ResponseWrapper<T> result(int code, String message) {
        return result(code, null, message);
    }

    default <T> ResponseWrapper<T> result(int code, T data, String message) {
        return ResponseWrapper.<T>builder()
                .code(code)
                .message(message)
                .data(data)
                .build();
    }
}
